//
// Created by Administrator on 2022/10/11.
//

#include "lock.h"

//或群读锁
int rwlock_rdlock(pthread_rwlock_t *lock)
{
    int err;
    err = pthread_rwlock_rdlock(lock);
    if(err == 0)
        return thread_ok;
    return thread_err;
}
//或群写锁
int rwlock_wrlock(pthread_rwlock_t *lock)
{
    int err;
    err = pthread_rwlock_wrlock(lock);
    if(err == 0)
        return thread_ok;
    return thread_err;
}
//
int rwlock_unlock(pthread_rwlock_t *lock)
{
    int err;
    err = pthread_rwlock_unlock(lock);
    if(err == 0)
        return thread_ok;
    return thread_err;
}
// 获取线程锁
int mutex_lock(pthread_mutex_t *lock)
{
    int err;
    err = pthread_mutex_lock(lock);
    if(err == 0)
        return thread_ok;
    return thread_err;
}
// 释放线程锁
int mutex_unlock(pthread_mutex_t *lock)
{
    int err;
    err = pthread_mutex_unlock(lock);
    if(err == 0)
        return thread_ok;
    return thread_err;
}